package com.only4play.authcenter.infrastructure.convert;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-03-04
 */
import com.only4play.authcenter.constants.ApplicationType;

import javax.persistence.AttributeConverter;

public class ApplicationTypeConverter implements AttributeConverter<ApplicationType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(ApplicationType applicationType) {
    return applicationType.getCode();
  }

  @Override
  public ApplicationType convertToEntityAttribute(Integer code) {
    return ApplicationType.of(code).orElse(null);
  }
}